﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls.Base;
using System.Drawing;

namespace Silvermoon.Controls
{
    /// <summary>
    /// ModalBackground is used by modal dialogs to darken the screen and disable touching or any interaction with the controls on the screen until the 
    /// modal dialog is closed.
    /// </summary>
    /// <remarks>
    /// This class is a decorator that has a transparent background and catches all IMouseEventBehaviors.
    /// </remarks>
    public class ModalBackground : Decorator
    {
        public ModalBackground()
            : base()
        {
            Margin = Margin.Zero;
        }
        #region IMouseEventBehavior Members

       internal protected override void OnTouchDown(TouchEventArgs e)
        {
            e.Handled = true;
            e.Handled = true;
        }

        internal protected override  void OnTouchUp(TouchEventArgs e)
        {
            e.Handled = true;
        }

        internal protected override void OnTap(TapEventArgs e)
        {
            e.Handled = true;
            e.Handled = true;
        }

        protected internal override void OnBeginPan(PanEventArgs e)
        {
            if (!e.Handled)
            {
                e.Handled = true;
            }
            base.OnBeginPan(e);
        }


        public override bool CanFocus { get { return false; } }

        protected override Silvermoon.Shapes.Shape CreateDefaultBackground()
        {
            return Color.Black;
        }

        #endregion
    }
}
